package com.demo.app.exception;


import com.demo.app.enums.CustomExceptionType;

/**
 * @Description: 自定义异常类
 * @Author: Wangzz
 * @Version: 1.0.0
 * @CreateDate: Created in 2021/10/31 22:34
 * @UpdateDate: [dateFormat:YYYY-MM-DD][modifier][description]
 */
public class CustomException extends RuntimeException{
    //异常错误编码
    private int code ;
    //异常信息
    private String message;

    private CustomException(){}

    public CustomException(CustomExceptionType exceptionTypeEnum) {
        this.code = exceptionTypeEnum.getCode();
        this.message = exceptionTypeEnum.getDescription();
    }

    public CustomException(CustomExceptionType exceptionTypeEnum,
                           String message) {
        this.code = exceptionTypeEnum.getCode();
        this.message = message;
    }

    public int getCode() {
        return code;
    }

    @Override
    public String getMessage() {
        return message;
    }
}
